<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: acer
  Date: 2019/7/7
  Time: 9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>

    <link rel="stylesheet" type="text/css" href="css/style.css">


<script src="js/jquery/2.0.0/jquery.min.js"></script>
<script src="js/bootstrap/3.3.6/bootstrap.min.js"></script>

<!-- start header -->

<header>
    <div class="top center">
        <div class="left fl">
            <ul>
                <li><a href="/home" >小米商城</a></li>
                <li>|</li>
                <li><a href="">MIUI</a></li>
                <li>|</li>
                <li><a href="">米聊</a></li>
                <li>|</li>
                <li><a href="">游戏</a></li>
                <li>|</li>
                <li><a href="">多看阅读</a></li>
                <li>|</li>
                <li><a href="">云服务</a></li>
                <li>|</li>
                <li><a href="">金融</a></li>
                <li>|</li>
                <li><a href="">小米商城移动版</a></li>
                <li>|</li>
                <li><a href="">问题反馈</a></li>
                <li>|</li>
                <li><a href="">Select Region</a></li>
                <div class="clear"></div>
            </ul>
        </div>
        <div class="right fr">
            <div class="gouwuche fr"><a href="javascript:void(0)" onclick="CartLink()">购物车</a></div>
            <div class="fr">
                <ul>
                    <c:choose>
                        <c:when test="${sessionScope.user.name==null}">

                            <li><a href="login" >登录</a></li>
                            <li>|</li>
                            <li><a href="register"  >注册</a></li>
                            <li>|</li>

                        </c:when>

                        <c:otherwise >
<%--                            <li><img src="http://localhost/${picture}" height="40" width="40" /></li>--%>
                            <li><a href="/person">${sessionScope.user.name}</a></li>
                            <li><a href="/logout">退出登录</a></li>
                            <li><a href="javascript:void(0)" onclick="collectionLink()">我的收藏</a></li>
                            <li><a href="bought">我的订单</a></li>
                        </c:otherwise>
                    </c:choose>
                </ul>
            </div>
        </div>
    </div>
    </header>
<script type="text/javascript">
    function CartLink() {
        var page = "/checkLogin";
        $.get(
            page,
            function (result) {
                if ("success" == result) {
                    location.href="/Cart"
                }
                else {
                    alert("未登录，请先登录！")
                }
            }
        );
        return false;
    }
    function collectionLink() {
        var page = "/checkLogin";
        $.get(
            page,
            function (result) {
                if ("success" == result) {
                    location.href="/pageshoucang"
                }
                else {
                    alert("未登录，请先登录！")
                }
            }
        );
        return false;
    }
</script>
</html>
